package org.zoomdev.zoom.dao.adapters.parameter;

import com.alibaba.fastjson2.JSON;
import org.zoomdev.zoom.dao.adapters.ParameterAdapter;

import java.sql.PreparedStatement;
import java.sql.SQLException;

public class JsonStringParameterAdapter implements ParameterAdapter {

    public static final JsonStringParameterAdapter ADAPTER = new JsonStringParameterAdapter();

    @Override
    public void setNonnullParameter(PreparedStatement ps, int index, Object data) throws SQLException {
        String str = JSON.toJSONString(data);
        ps.setString(index, str);
    }
}
